#include <algorithm>
#include <cstdio>
#include <cstring>
constexpr int MaxN = 1e3 + 5;
int n, k;
long long p[MaxN];
long long dp[MaxN][MaxN];
bool check(long long x)
{
    memset(dp, 0x3f, sizeof(dp));
    dp[1][1] = p[1];
    for (int i = 2; i <= n; i++)
    {
        dp[i][1] = std::min(dp[i][1], p[i]);
        for (int j = 1; j <= i - 1; j++)
        {
            for (int k = 2; k <= j + 1; k++)
            {
                if (p[j] + p[i] > x)
                {
                    continue;
                }
                dp[i][k] = std::min(dp[i][k], dp[j][k - 1]);
            }
        }
    }
    bool suc = false;
    for (int i = 1; i <= n; i++)
    {
        suc |= dp[i][k] != 0x3f3f3f3f'3f3f3f3f && dp[i][k] + p[i] <= x;
    }
    return suc;
}
int main()
{
    freopen("sub.in", "r", stdin);
    freopen("sub.out", "w", stdout);
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; i++)
    {
        scanf("%lld", &p[i]);
    }
    long long l, r;
    l = 1;
    r = 2e9;
    long long result = -1;
    for (; l <= r;)
    {
        long long mid = (l + r) / 2;
        if (check(mid))
        {
            r = mid - 1;
            result = mid;
        }
        else
        {
            l = mid + 1;
        }
    }
    printf("%lld\n", result);
    return 0;
}